package com.transsion.clouddemo.core.Custom.utils

import android.content.Context
import android.content.SharedPreferences
import com.transsion.clouddemo.CloudApplication.Companion.context

object SPUtils {

    private val sp :SharedPreferences by lazy {
        context.getSharedPreferences(CLOUD_SP, Context.MODE_PRIVATE)
    }
    private val CLOUD_SP="CLOUD_SP"


    fun putString(key: String, value: String) {
        val editor = sp.edit() // 通过 sp 获取 SharedPreferences 实例
        editor.putString(key, value)
            editor.apply()
    }

    fun putInt(key: String, value: Int) {
        val editor = sp.edit() // 通过 sp 获取 SharedPreferences 实例
        editor.putInt(key, value)
        editor.apply()
    }

    fun getString(key: String, def: String = ""): String? {
        return sp.getString(key, def)
    }

    fun getInt(key: String): Int {
        return sp.getInt(key, -1)
    }

    fun clearAll() {
         sp.edit().clear().apply()
    }


}